package top.kaoshanji.q1ch03a.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import top.kaoshanji.q1ch03a.domain.LoginLog;

/**
 * @author kaoshanji
 * ^_^
 * create time 2025/5/3 17:50
 */
@Repository
public class LoginLogDao {

    private JdbcTemplate jdbcTemplate;

    @Autowired
    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    // 插入登录日志SQL语句
    private final static String INSERT_LOGIN_LOG_SQL= " INSERT INTO t_login_log(user_id, ip, login_datetime) VALUES(?, ?, ?) ";

    /**
     * 插入登录日志记录
     * @param loginLog LoginLog
     */
    public void insertLoginLog(LoginLog loginLog) {
        jdbcTemplate.update(INSERT_LOGIN_LOG_SQL, loginLog.getUserId(), loginLog.getIp(), loginLog.getLoginDate());
    }

}
